import numpy as np
import cv2 as cv
import math
import os
import sys
sys.path.append(os.getcwd())
from config.env import Env
env = Env()

img = cv.imread(env.getImgPath() + 'meinv1.jpg')

print(img.shape)
'''
三点位置转换
'''
rows, cols, ch = img.shape
pst1 = np.float32([[50, 50], [100, 50], [50, 200]])
pst2 = np.float32([[10, 100], [100, 50], [100, 250]])
M = cv.getAffineTransform(pst1, pst2)
dst = cv.warpAffine(img, M, (cols, rows))

'''
透视转换
'''
psts3 = np.float32([[200, 65], [412, 52], [172, 357], [433, 360]])
psts4 = np.float32([[0, 0], [230, 0], [0, 300], [230, 300]])
M2 = cv.getPerspectiveTransform(psts3, psts4)
dst2 = cv.warpPerspective(img, M2, (230, 300))

cv.imshow("img", dst2)
cv.waitKey(0)
cv.destroyAllWindows()
